package com.dsz.du.mealbooking.dao;

import java.util.List;

import javax.jdo.PersistenceManager;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import com.dsz.du.gaesuport.MyPersistenceManagerFactory;
import com.dsz.du.mealbooking.model.MealModel;
import com.dsz.du.mealbooking.model.UserModel;

@Repository(value="bookMealGAEDao")
public class BookMealDaoGAEImp extends BaseDao implements BookMealDao {
	
	private static Logger logger = Logger.getLogger(BookMealDaoGAEImp.class);
	
	@Override
	public void addOrder(String userId, List<String> mealIds) {

	}
	
	@Override
	public void addMeal(String userId, String mealId) {
		if (logger.isDebugEnabled()){
			logger.debug("add meal mealId is : " + mealId);
		}
	}

	@Override
	public void addMeal(UserModel userWithMeal) {
		
		super.saveModel(userWithMeal);
	}
	
	@Override
	public void deleteMeal(String userId, String mealIds) {
	}	

	@Override
	public List<MealModel> listOrder(String userId) {
	    PersistenceManager pm = MyPersistenceManagerFactory.getInstance().getPersistenceManager();
	    String query = "select from " + MealModel.class.getName();
	    List<MealModel> meals = (List<MealModel>) pm.newQuery(query).execute();
		return meals;
	}

	@Override
	public void removeOrder(String userId) {
		// TODO Auto-generated method stub
		
	}
}
